﻿@using Kojarskiy.Core
@model Kojarskiy.Models.SiteMap
@{
    List<ContentBlock> blocks = null;
    bool showLeftPart = false;
    bool showRightPart = false;
    
    if(ViewData["PageBlocks"] != null)
    {
        blocks = ContentBlock.ParseLayout(ViewData["PageBlocks"].ToString());
        foreach (var contentBlock in blocks)
        {
            if(contentBlock.Column == 1) {showLeftPart = true;}
            if(contentBlock.Column == 5) {showRightPart = true;}
        }
    }
}

@if (Model.Parent.ParentId != null)
{
    @Html.ActionLink("Главная", "Index", "Home")<text>| @Html.ActionLink(Model.Parent.PageName, "Page", "Home", new { page = Model.Parent.Path }, null) | @Model.PageName </text>
}
else
{
    @Html.ActionLink("Главная", "Index", "Home")<text>| @Model.PageName </text>
}
<div style="clear: both;"></div>

@if (User.IsInRole("Administrators"))
{
<div class="form-group f_r">
    <button type="button" onclick="location.href='@Url.Action("Edit", "SiteMap", new { id = Model.SiteMapId, returnUrl = Request.RawUrl })'" 
        class="btn btn-sm btn-warning">Редактировать страницу</button>
</div>
}
<h1>@Model.PageName</h1>
<div class="f_l">
    @foreach (var block in blocks.Where(x => x.Column == 1))
    {
        @Html.Partial("_Block", block.Type, new ViewDataDictionary() {new KeyValuePair<string, object>("SiteMapNode", Model) })
    }
</div>
<div class="f_r" style="width: 100%; max-width: 770px;">
    <fieldset>
        <legend>Заполните необходимые поля</legend>
        @using (Html.BeginForm("Question", "Home", FormMethod.Post, new { id = "QuestionForm", @class = "form-horizontal" }))
        {
            
            @Html.HiddenFor(x => x.SiteMapId)

            <div class="form-group">
                <label class="control-label">Вид услуги<span style="color: red;">*</span></label>
                <input type="text" data-bv-notempty data-bv-notempty-message="Заполните поле" name="ServiceType" class="form-control"/>
            </div>

            <div class="form-group">Наименование Заказчика<span style="color: red;">*</span>
                <input type="text" name="ClientName" data-bv-notempty data-bv-notempty-message="Заполните поле" class="form-control"/></div>

            <div class="form-group">Адрес<span style="color: red;">*</span>  
                <input type="text" name="Address" data-bv-notempty data-bv-notempty-message="Заполните поле" class="form-control"/></div>

            <div class="form-group">Контактный телефон<span style="color: red;">*</span>
                <input type="text" name="Phone" data-bv-notempty data-bv-notempty-message="Заполните поле" class="form-control"/></div>

            <div class="form-group">E-mail<span style="color: red;">*</span>
                <input type="email" name="Email" 
                       data-bv-emailaddress-message="Не корректный email"
                       data-bv-notempty data-bv-notempty-message="Заполните поле" class="form-control"/></div>

            <div class="form-group">Содержание запроса<span style="color: red;">*</span>
                <textarea name="Request" rows="5" data-bv-notempty data-bv-notempty-message="Заполните поле" class="form-control"></textarea></div>

            <div class="form-actions">
                <button type="submit" name="Submit" class="btn btn-success">Отправить запрос</button>
            </div>
        }

    </fieldset>
</div>

<script>
    $(document).ready(function () {
        $('#QuestionForm').bootstrapValidator({ excluded: [':disabled', ':hidden', ':not(:visible)'], submitButtons: 'button[type="submit"]'});
    });
</script>

